<?php
require_once(dirname(__FILE__)."/../config/session.php");
require_once(dirname(__FILE__)."/../config/config.inc.php");
require_once(dirname(__FILE__)."/../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../libs/dbclass/dbconn.php");
require_once(dirname(__FILE__)."/../libs/dbclass/dbservice.php");
require_once(dirname(__FILE__)."/../libs/login/login.php");
require_once(dirname(__FILE__)."/../libs/io/fileclass.php");
$mc=new libstr();
$db=new dbconn();
$dbs=new dbservice();
$lp=new login();
$fil=new fileclass();
//set_time_limit(0);
ob_implicit_flush();
$str="406661940B85054B984A7407140F9BEBAF2282B1715B90CA7FDC5755A2327061356B211AD7EECCE37427616D853F4651AE8781C2004A1A598F25E7162D1C4C096E13A650435F5551DA83B565966E675430B8BF557BB14386404F7DF135489BA509D59D78F70B04737BAA46FEF1D77E4D54351CA76D2C83880572E0B00719ACA75C78B7C7F550279A275695EEC76AC6485972AE6008EFBBD92D43BFF6CFD3F70ABC57119F3DF5218E8105EB862A9BF5BBB82E4AC2A6FCE0C6820AF7A04DD1008DE606DA71660260F491BAAFEDD65A94D178E0032DE2529A643C6C7D26BFE5146666A380C3F479C9A4705116858DD87D2A9F0830B91A3418FDAC692F3A81421668";
//$a1= substr($str,0,256);
//$a2=substr($str,256,strlen($str));
//echo $a1."----".strlen($a1);
//exit();

if($mc->Ismp(trim($_GET["userid"]))!="wldbook")
{
echo "-1";
exit();
}
if($mc->Ismp(trim($_GET["password"]))!="hao123")
{
echo "-1";
exit();
}
if($mc->Ismp(trim($_GET["keycode"]))=="")
{
echo "0";
exit();
}
if($mc->Ismp(trim($_GET["keydata"]))=="")
{
echo "1";
exit();
}
if(!$mc->isnum($_GET["keycode"]))
{
//echo "2";
//exit();
}

if(strlen(trim($_GET["keycode"]))>28)
{
echo "3";
exit();
}

$rs=$db->dvstr("select count(id) as k from keycontent where keycode='".trim($_GET["keycode"])."'");
if($rs["k"]!="0")
{
//$db->cmd("update keycontent set keydata='".trim($_GET["keydata"])."' where keycode='".trim($_GET["keycode"])."'");
echo "4";
exit();
}
$db->cmd("insert into keycontent(keycode,keydata,createtime)values('".trim($_GET["keycode"])."','".trim($_GET["keydata"])."','".date("Y-m-d H:i:s")."')");
echo "5";
?>